package com.hyz.login.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyz.login.model.Pharmacy;
import com.hyz.login.mapper.PharmacyMapper;
import com.hyz.login.service.PharmacyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zwq
 * @since 2022-11-21
 */
@Service
public class PharmacyServiceImpl
        extends ServiceImpl<PharmacyMapper, Pharmacy> implements PharmacyService {

    @Autowired
    private PharmacyMapper pharmacyMapper;
    @Override
    
    public IPage<Pharmacy> findAll(String durgname,Integer page,Integer limit) {
        QueryWrapper<Pharmacy> wrapper = new QueryWrapper<Pharmacy>();
        wrapper.like("pharmacyName",durgname);
        IPage<Pharmacy> iPage = new Page<Pharmacy>();
        iPage.setRecords(pharmacyMapper.findAll(durgname, page-1, limit));
        iPage.setCurrent(pharmacyMapper.selectCount(wrapper));
        iPage.setCurrent(page);
        iPage.setSize(limit);
        return iPage;
    }

    @Override
    public Integer modifyDrugstorenum(String pharmacyName, Integer drugstorenum) {
        return pharmacyMapper.modifyDrugstorenum(pharmacyName, drugstorenum);
    }

    @Override
    public Integer addDrugstorenum(String pharmacyName, Integer drugstorenum) {
        return pharmacyMapper.addDrugstorenum(pharmacyName, drugstorenum);
    }

    @Override
    public Pharmacy findNumById(Integer pharmacyId) {
        return pharmacyMapper.findNumById(pharmacyId);
    }

}
